unit Thrad_TestUNI;

interface

uses
  Classes,SysUtils,Uni,Class_KzThrad,UniConfig,UniConnct;

type
  TThradTestUNI = class(TKzThrad)
  public
    FSRVRNAME:string;
    FDATABASE:string;
    FUSERNAME:string;
    FPASSWORD:string;
  protected
    procedure Execute; override;
  end;

implementation
uses
  ActiveX;


procedure TThradTestUNI.Execute;
var
  I:Integer;
  Objt:TUniConnection;
begin
  try
    CoInitialize(nil);

    GetMsgProgress('START',[]);

    GetMaxProgress(20);
    for I:=0 to 19 do
    begin
      GetOneProgress(I+1);
      try
        try
          Objt:=TUniConnection.Create(nil);
          Objt.LoginPrompt:=False;
          Objt.ProviderName:=CONST_PROVIDER_SQLSRV;
          Objt.Username    :=FUSERNAME;
          Objt.Password    :=FPASSWORD;
          Objt.Database    :=FDATABASE;
          Objt.Server      :=FSRVRNAME;
          Objt.Port        :=1433;
          Objt.PerformConnect();
          GetMsgProgress(Class_KzThrad.CONST_THRAD_STAT_TRUE,[I+1]);
          Sleep(1000 * 10);
        except
          on E:Exception do
          begin
            GetMsgProgress(Class_KzThrad.CONST_THRAD_STAT_EROR,[I+1,E.Message]);
          end;
        end;
      finally
        FreeAndNil(Objt);
      end;
    end;

    GetMaxProgress(0);
    GetOneProgress(0);

    GetMsgProgress('ENDED',[]);
  finally
    CoUninitialize;
  end;
end;

end.
